<template>
  <div class="order">
    <van-nav-bar title="我的订单" />
    <van-tabs v-model="active" @click="tabClick">
      <van-tab :title="item" v-for="(item, index) in title" :key="index">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <OrderBox :listData="listData"></OrderBox>
        </van-list>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { get } from "@/utils/request.js";
import OrderBox from "@/components/OrderBox.vue";
export default {
  data() {
    return {
      active: 0,
      value: "",
      params: {
        page: 1,
        pageSize: 100,
        status: "待接单",
      },
      title: ["进行中", "已完成"],
      listData: [],
      loading: false,
      finished: false,
    };
  },
  components: {
    OrderBox,
  },
  created() {
    this.params.status = "进行中";
    this.getOrdersByStatus();
  },
  methods: {
    getOrdersByStatus() {
      get("/workorder/pageQuery", this.params).then((res) => {
        this.listData = res.data.list;
      });
    },
    onLoad() {},
    tabClick(name, title) {
      this.params.status = title;
      this.getOrdersByStatus();
    },
  },
};
</script>

<style>
</style>